import { Refresh } from '@element-plus/icons-vue';
import { createStore } from 'vuex';

export default createStore({
  state: {
    userInfo: null,
    token: '',
    refreshToken: '',
  },
  mutations: {
    setUserInfo(state, userInfo) {
      state.userInfo = userInfo;
    },
    token(state, token) {
      state.token = token;
    },
    refreshToken(state, refreshToken) {
      state.refreshToken = refreshToken;
    },
    delete(state){
      state.refreshToken = null;
      state.token = null;
      state.refreshToken = null;
    }
  },
  actions: {
    setUserInfo({ commit }, userInfo) {
      commit('setUserInfo', userInfo);
    },
    setToken({ commit }, token) {
      commit('setToken', token);
    },
    setRefreshToken({ commit }, refreshToken) {
      commit('setRefreshToken', refreshToken);
    },
  },
  getters: {
    storage(state) {
      return state;
    },
  },
});